package Course13;

public class Mistake4 {
    public static void Test1(int x)throws ArrayIndexOutOfBoundsException,ArithmeticException{
        if(x==0){
            System.out.println("没有异常");
        }
        else if(x==1){
        int[]a=new int[3];
            a[3]=5;
        }

        else if(x==2){
            int i=0;
            if(i==0){
            throw new ArithmeticException("除数不能为0！！！");}
            int j=5/0;
        }

    }

    public static void main(String[] args) {
        try{
            Test1(1);
        }catch(ArrayIndexOutOfBoundsException e){
            System.out.println(e.getMessage());
            System.out.println("数组越界啦！！！");
        }
        try{
            Test1(2);
        }catch(ArithmeticException e){
            System.out.println(e.getMessage());
        }
    }
}
